﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Commerce/Views/Shared/Backend.Master"
    Inherits="System.Web.Mvc.ViewPage<IQueryable<IPromotionRule>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    <%:"Promotions".Localize()%>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h3 class="title">
        <%:"Promotions".Localize() %></h3>
    <div class="command">
        <ul class="clearfix">
            <li><a href='<%= ViewData["add_action"] %>' class="button">
                <%:"Create Promotion".Localize()%></a></li>
        </ul>
    </div>
    <div class="table-container">
        <table>
            <thead>
                <tr>
                    <th class="action">
                        <%: "Enabled".Localize() %>
                    </th>
                    <th>
                        <%:"Name".Localize() %>
                    </th>
                    <th>
                        <%:"Start date".Localize() %>
                    </th>
                    <th>
                        <%:"End date".Localize() %>
                    </th>
                    <th>
                        <%:"Priority".Localize()%>
                    </th>
                    <th>
                        <%:"Promotion name".Localize() %>
                    </th>
              
                    <th class="action">
                        <%:"Edit".Localize() %>
                    </th>
                    <th class="action">
                        <%:"Delete".Localize() %>
                    </th>
                </tr>
            </thead>
            <tbody>
                <% 
                    var index = 0;
                    foreach (var item in Model)
                    {
                %>
                <tr <% if (++index % 2 == 0) {%>class="even" <%} %>>
                    <td class="action">
                        <a href="#" class='o-icon <%= item.IsEnable?"tick":"cross" %>'></a>
                    </td>
                    <td>
                        <%: item.Name%>
                    </td>
                    <td>
                        <%: item.StartDate%>
                    </td>
                    <td>
                        <%: item.EndDate%>
                    </td>
                    <td>
                        <%: item.Priority%>
                    </td>
                    <td>
                        <%: item.PromotionName%>
                    </td>
           
                    <td class="action">
                        <%: Html.ActionLink(" ", "Edit", "PromotionRule", new { Id = item.Id }, new { @class = "o-icon edit", title = "edit".Localize() })%>
                    </td>
                    <td class="action">
                        <form class="delete-form" action='<%= ViewData["delete_action"] %>'>
                        <input type="submit" class="o-icon input-icon delete delete-link" message='<%= "Are you sure you want to delete this rule?".Localize() %>'
                            value="<%:"Delete".Localize() %>" />
                        <input type="hidden" name="Id" value='<%= item.Id %>' />
                        </form>
                    </td>
                </tr>
                <%
                    }
                %>
            </tbody>
        </table>
    </div>
</asp:Content>
<asp:Content ContentPlaceHolderID="ScriptContent" ID="ScriptContent" runat="server">
    <%using (var loader = ClientLoader.RegisterInstance())
      {
          loader.Require("promotionrule.index.js");
      } %>
</asp:Content>
